;(function(){
  // var ecStat = require('echarts-stat');
  $.ajax({
    url: "data/data3.json", //json文件位置
    type: "get",
    dataType: "json", //返回数据格式为json
    success: function (data3) { //请求成功完成后要执行的方法

      var chartDom = document.getElementById('main3');
      var myChart = echarts.init(chartDom,'dark');
      // var myChart = echarts.init(chartDom);
      var option;
      
      // See https://github.com/ecomfe/echarts-stat
      echarts.registerTransform(ecStat.transform.regression);
      const data = data3.data3;
      option = {
        background:'',
        dataset: [
          {
            source: data
          },
          {
            transform: {
              type: 'ecStat:regression'
              // 'linear' by default.
              // config: { method: 'linear', formulaOn: 'end'}
            }
          }
        ],
        title: {
          text: '毕业生平均工资（万元）',
          // subtext: 'By ecStat.regression',
          sublink: 'https://github.com/ecomfe/echarts-stat',
          left: 'center'
        },
        legend: {
          bottom: 5
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            
          }
        },
        xAxis: {
          splitLine: {
            lineStyle: {
              type: 'dashed'
            }
          },
          min: 2017,
          max: 2022,
          interval: 1
        },
        yAxis: {
          splitLine: {
            lineStyle: {
              type: 'dashed'
            }
          }
        },
        series: [
          {
            name: '个人平均工资',
            type: 'scatter'
          },
          {
            name: '线性回归方程统计直线',
            type: 'line',
            datasetIndex: 1,
            symbolSize: 0.1,
            symbol: 'circle',
            label: { show: true, fontSize: 16 },
            labelLayout: { dx: -20 },
            encode: { label: 2, tooltip: 1 }
          }
        ]
      };
      
      option && myChart.setOption(option);
      window.onresize = myChart.resize;
    }
    })
 
  
    
})();